package com.java.comprehensive.arithmetic.leecode.easy;

/**
 * @program: comprehensive-service
 *
 * @description: 移除元素
 *
 * @author: 窦绍飞
 *
 * @create: 2021-11-17 17:54
 **/
public class LeetCode_27 {

	public static int removeElement(int[] nums, int val) {
		if (nums.length == 0) {
			return 0;
		}
		int j = 0;
		for (int i = 0; i < nums.length; i++) {
			if(nums[i] != val){
				nums[j] = nums[i];
				j++;
			}
		}
		return j;
	}

	public static void main(String[] args) {
		int[] nums = { 3,2,2,3 };
		int i = removeElement(nums,2);
		System.out.println(i);

	}

}
